package com.lgcns.android.otmeal.rest;

import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Window;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.lgcns.android.otmeal.AbstractAsyncActivity;

public class HomeActivity extends AbstractAsyncActivity 
{
//	private static final String TAG = TwitterOAuthActivity.class.getSimpleName();
	WebView wb = null;
	
	//***************************************
    // Activity methods
    //***************************************
	@Override
	public void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
	      requestWindowFeature(Window.FEATURE_NO_TITLE);
	     wb = new WebView(this);
	     wb.setWebViewClient(new HelloWebViewClient());
	     wb.getSettings().setJavaScriptEnabled(true);
	     wb.loadUrl("http://10.0.2.2:8080/lgcns-otmeal-server");
	     setContentView(wb);
	}
	
    private class HelloWebViewClient extends WebViewClient {

    	public boolean shouldOverrideUrlLoading(WebView view, String url) {
        	view.loadUrl(url);
         	return true;
        }
	}

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK && wb.canGoBack())
        	wb.goBack();
        return super.onKeyDown(keyCode, event);
	}
}
